package com.xuchaotong.utils;

import com.xuchaotong.entity.User;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;

/**
 * @author 311633
 * @version 1.0
 * @ClassName:
 * @Description:
 * @date 2018/1/26 14:46
 */
public class CollectionDemo {
    public static void main(String[] args) {
        List<User> userList = new ArrayList<>();
        User u1 = new User();
        u1.setName("John");

        User u2 = new User();
        u2.setName("John1");

        User u3 = new User();
        u3.setName("John2");

        User u4 = new User();
        u4.setName("John3");

        userList.add(u1);
        userList.add(u2);
        userList.add(u3);
        userList.add(u4);

        Set<String> nSet = userList.stream().map(User::getName).collect(Collectors.toSet());

        System.out.println(nSet);
    }

}
